<!DOCTYPE HTML>
<html lang="en">
<head>
<title>#MaxMem - Syntax &amp; Usage | AutoHotkey</title>
<meta name="description" content="The #MaxMem directive sets the maximum capacity of each variable to the specified number of megabytes." />
<meta name="ahk:equiv-v2" content="AutoHotkey.htm" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>#MaxMem</h1>

<p>Sets the maximum capacity of each <a href="../Variables.htm">variable</a> to the specified number of megabytes.</p>

<pre class="Syntax"><span class="func">#MaxMem</span> Megabytes</pre>
<h2>Parameters</h2>
<dl>

  <dt>Megabytes</dt>
  <dd><p>The number of megabytes to allow for each <a href="../Variables.htm">variable</a>. A value larger than 4095 is considered to be 4095. A value less than 1 is considered to be 1.</p></dd>

</dl>
<h2>Remarks</h2>
<p>If this directive is unspecified in the script, it will behave as though set to 64.</p>
<p>The purpose of limiting each variable's capacity is to prevent a buggy script from consuming all available system memory. Raising or lowering the limit does not affect the performance of a script, nor does it change how much memory the script actually uses (except in the case of <a href="WinGetText.htm">WinGetText</a> and <a href="ControlGetText.htm">ControlGetText</a>, which will be capable of retrieving more text if #MaxMem is increased).</p>
<p>This setting is global, meaning that it needs to be specified only once (anywhere in the script) to affect the behavior of the entire script.</p>
<p>This setting restricts only the automatic expansion that a variable does on its own. It does not affect <a href="VarSetCapacity.htm">VarSetCapacity()</a>.</p>
<h2>Related</h2>
<p><a href="VarSetCapacity.htm">VarSetCapacity()</a>, <a href="../Variables.htm">Variables</a>, <a href="Sort.htm">Sort</a>, <a href="WinGetText.htm">WinGetText</a>, <a href="ControlGetText.htm">ControlGetText</a>, <a href="_MaxThreads.htm">#MaxThreads</a></p>
<h2>Examples</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>#MaxMem 256  <em>; Allow 256 MB per variable.</em></pre>
</div>

</body>
</html>
